package com.servlet.type;

import com.dao.TypeDao;
import com.dao.TypeInfo;
import com.entity.Type;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * @author admin
 */
@WebServlet(name = "TypeSelectAllServlet",urlPatterns = "/TypeSelectAllServlet.filter")
public class TypeSelectAllServlet extends HttpServlet {
//    private String encoding;


    private TypeDao typeDao = new TypeInfo();


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("TypeSelectAllServlet");
        try {
            List<Type> typeList = typeDao.typeSelectAll();
            System.out.println("typeList+"+typeList.size());
            request.setAttribute("typeList",typeList);
            request.getRequestDispatcher("/WEB-INF/page/type.jsp").forward(request,response);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
